var loginObject = new Object();
$(function () {
    var error = $("#error").val();
    if (error != null && error != "") {
        alert(error);
    }
    loginObject.init();
    loginObject.regListenEvent();
});

loginObject.init = function () {

};
loginObject.regListenEvent = function () {
    //监听回车事件
    $(window).keydown(function (event) {
        if (event.keyCode == 13) {
            login();
        }
    });

    //监听登录事件
    $('#submitBtn').click(function (event) {
        // event.stopPropagation();
        login();
    });
};

function passwordReset() {
    var src = $("#passwordReset").attr("src");
    location.href = src;
}
function login() {


    var userAccount = $("#userAccount").val();
    var userPassword = $("#userPassword").val();
    if (userAccount && userPassword) {
        var veryCode = $("#veryCode").val();
        if (veryCode != null && veryCode != undefined && veryCode != "") {
            $('#loginForm').submit();
        } else {
            alert("请输入验证码");
        }
    } else {
        alert("请输入账号和密码");
    }

}
function changeCode() {

    var imgSrc = $("#kaptchaImage");
    var src = imgSrc.attr("src");
    imgSrc.attr("src", chgUrl(src));
}
//时间戳
//为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳
function chgUrl(url) {
    var timestamp = (new Date()).valueOf();
    var urlurl = url.substring(0, 17);
    if ((url.indexOf("&") >= 0)) {
        urlurl = url + "×tamp=" + timestamp;
    } else {
        urlurl = url + "?timestamp=" + timestamp;
    }
    return urlurl;
}